//
//  FPMovieTableViewCell.m
//  FilmParadise
//
//  Created by lanou3g on 15/7/13.
//  Copyright (c) 2015年 DLYgroup. All rights reserved.
//

#import "FPMovieTableViewCell.h"

@implementation FPMovieTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self B_tableViewCell];
    }
    return self;
}

// 创建视图
- (void)B_tableViewCell
{
    // 电影图片
    self.displyImageView = [[UIImageView alloc] initWithFrame:CGRectMake(15, 15, (kScreenWidth - 30) / 4.5, (kScreenHeight - 96) / 3.5 - 40)];
//    self.displyImageView.image = [UIImage imageNamed:@""];
    self.displyImageView.backgroundColor = [UIColor magentaColor];
    [self.contentView addSubview:_displyImageView];
    
    // 影片名
    self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake((kScreenWidth - 30) / 4.5 + 35, 15, 0, 30)];
    self.titleLabel.text = @"栀子花开";
    self.titleLabel.font = [UIFont systemFontOfSize:18.0 weight:2.0];
    [self.contentView addSubview:_titleLabel];
    
    // 影片评分
    self.markLabel = [UILabel labelWithFrame:CGRectMake( kScreenWidth - 50, 15, kScreenWidth - (kScreenWidth - 30) / 4.5 - 50, 30) text:@"3.6" fontSize:21.0 fontWeight:1.0 color:[UIColor colorWithRed:0.287 green:0.745 blue:0.076 alpha:1.000]];
    self.markLabel.font = [UIFont fontWithName:@"GillSans-Light" size:21.0];
    NSMutableAttributedString *str = [[NSMutableAttributedString alloc]initWithString:_markLabel.text];
    [str addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"GillSans-Light" size:25.0] range:NSMakeRange(0, 1)];
    [self.contentView addSubview:_markLabel];
    
    // 影片简介(橘色内容)
    self.contentLable = [[UILabel alloc] initWithFrame:CGRectMake((kScreenWidth - 30) / 4.5 + 35, 35, kScreenWidth - (kScreenWidth - 30) / 4.5 - 50, 30)];
    self.contentLable.text = @"“考验真心粉的时候到了!";
    self.contentLable.textColor = [UIColor orangeColor];
    self.contentLable.font = [UIFont systemFontOfSize:15.0];
    [self.contentView addSubview:_contentLable];
    
    // 上映日期
    self.screenDateLabel = [[UILabel alloc] initWithFrame:CGRectMake((kScreenWidth - 30) / 4.5 + 35, 60, kScreenWidth - (kScreenWidth - 30) / 4.5 - 50, 30)];
    self.screenDateLabel.text = @"7月10日上映";
    self.screenDateLabel.textColor = [UIColor colorWithRed:0.747 green:0.731 blue:0.623 alpha:1.000];
    self.screenDateLabel.font = [UIFont systemFontOfSize:12.0];
    [self.contentView addSubview:_screenDateLabel];
    
    // 影院场次
    self.cinemaNumLabel = [UILabel labelWithFrame:CGRectMake((kScreenWidth - 30) / 4.5 + 35, 85, kScreenWidth - (kScreenWidth - 30) / 4.5 - 50, 30) text:@"今日135家影院  1093场" fontSize:12.0 fontWeight:1.0 color:[UIColor colorWithRed:0.747 green:0.731 blue:0.623 alpha:1.000]];
    [self.contentView addSubview:_cinemaNumLabel];
    
    // 是否为3D电影
    self.thirdDLabel = [UILabel labelWithFrame:CGRectMake((kScreenWidth - 30) / 4.5 + 35, 115, 20, 20) text:@"3D" fontSize:9 fontWeight:1 color:[UIColor colorWithRed:0.747 green:0.731 blue:0.623 alpha:1.000]];
    self.thirdDLabel.layer.borderWidth = 2.0;
    self.thirdDLabel.layer.borderColor = [UIColor colorWithRed:0.747 green:0.731 blue:0.623 alpha:1.000].CGColor;
    self.thirdDLabel.layer.cornerRadius = 5.0;
    self.thirdDLabel.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:_thirdDLabel];
    
    // 是否是中国巨幕
    self.chinaLabel = [UILabel labelWithFrame:CGRectMake((kScreenWidth - 30) / 4.5 + 60, 115, 50, 20) text:@"中国巨幕" fontSize:9 fontWeight:1 color:[UIColor colorWithRed:0.747 green:0.731 blue:0.623 alpha:1.000]];
    self.chinaLabel.layer.borderWidth = 2.0;
    self.chinaLabel.layer.borderColor = [UIColor colorWithRed:0.747 green:0.731 blue:0.623 alpha:1.000].CGColor;
    self.chinaLabel.layer.cornerRadius = 5.0;
    self.chinaLabel.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:_chinaLabel];
    
    // 是否为IMAX
    self.imaxLabel = [UILabel labelWithFrame:CGRectMake((kScreenWidth - 30) / 4.5 + 115, 115, 40, 20) text:@"IMAX" fontSize:9 fontWeight:1 color:[UIColor colorWithRed:0.747 green:0.731 blue:0.623 alpha:1.000]];
    self.imaxLabel.layer.borderWidth = 2.0;
    self.imaxLabel.layer.borderColor = [UIColor colorWithRed:0.747 green:0.731 blue:0.623 alpha:1.000].CGColor;
    self.imaxLabel.layer.cornerRadius = 5.0;
    self.imaxLabel.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:_imaxLabel];
}
/* 此界面所有控件:
displyImageView; // 影片图片
markLabel;       // 评分
titleLabel;      // 影片名
contentLeble;    // 橘色内容
screenDateLabel; // 上映日期
cinemaNumLabel;  // 影院场次
thirdDLabel;     // 是否为3D
chinaLabel;      // 是否是巨幕影院
imaxLabel;       // 是否为IMAX
*/
//动态计算content宽度
- (void)adjustSubviewsWithContent:(NSString *)content
{
    CGRect contentBounds = [content boundingRectWithSize:CGSizeMake(999, 30)
                                                 options:NSStringDrawingUsesLineFragmentOrigin
                                              attributes:[NSDictionary
                                                          dictionaryWithObject:
                                                          [UIFont systemFontOfSize:18.0]
                                                          forKey:NSFontAttributeName] context:nil];
   _titleLabel.width = contentBounds.size.width + 5;
    _markLabel.x = _titleLabel.x + _titleLabel.width + kImageW(10);
    _markLabel.font = [UIFont systemFontOfSize:21.0 weight:1.0];
    
}



- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
